package com.anttribe.components.db.metadata.entity;

import lombok.Getter;

import java.sql.DatabaseMetaData;

/**
 * @author zhaoyong
 * @date 2021/10/29 0029
 */
@Getter
public enum DbIndexType {

    TABLE_INDEX_STATISTIC(DatabaseMetaData.tableIndexStatistic), TABLE_INDEX_CLUSTERED(DatabaseMetaData.tableIndexClustered), TABLE_INDEX_HASHED(DatabaseMetaData.tableIndexHashed), TABLE_INDEX_OTHER(DatabaseMetaData.tableIndexOther);

    private short type;

    DbIndexType(short type) {
        this.type = type;
    }

    public static DbIndexType valueOfType(short type) {
        DbIndexType[] indexTypes = DbIndexType.values();
        for (DbIndexType indexType : indexTypes) {
            if (indexType.getType() == type) {
                return indexType;
            }
        }
        return null;
    }
}
